package com.winit.openapi.es.vo;

import java.util.Date;

import com.winit.tracing.common.utils.Clock;

/**
 * Created by jianke.zhang on 2017/2/21.
 */
public class SpanQuery extends Span{

    private int    cycle;

    private int    offset;

    private int    limit;

    private String keyword;

    private Long startTimestamp;

    private Long endTimestamp;

    public int getCycle() {
        return cycle;
    }

    public void setCycle(int cycle) {
        this.cycle = cycle;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }
    public int getLimit() {
        if (this.limit < 1) {
            this.limit = 10;
        }
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getPageNo() {
        return this.offset / this.getLimit() + 1;
    }

    public int getPageSize() {
        return this.limit;
    }

    public Long getStartTimestamp() {
        return startTimestamp;
    }

    public void setStartTimestamp(Long startTimestamp) {
        this.startTimestamp = startTimestamp;
    }

    public Long getEndTimestamp() {
        return endTimestamp;
    }

    public void setEndTimestamp(Long endTimestamp) {
        this.endTimestamp = endTimestamp;
    }

    public Date getStartDate() {
        return Clock.getDate(startTimestamp);
    }

    public Date getEndDate() {
        return Clock.getDate(endTimestamp);
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
}
